package com.live.service;

import java.util.List;

import com.live.dao.ContractDao;
import com.live.model.Contract;

public class ContractService {
	private ContractDao cntractDao = new ContractDao();
	public int addContract(Contract contract) {
		return cntractDao.addContract(contract);
	}
	public int editContract(Contract 	contract) {
		return cntractDao.editContract(contract);
	}
	public List<Contract> getPageContract(String firstPartyName, int pageIndex,
			int pageSize) {
		return cntractDao.getPageContract(firstPartyName, pageIndex, pageSize);
	}
	public int getTotalPage(String firstPartyName,int pageSize) {
		int totalCount =  cntractDao.getTotalCount(firstPartyName);
		int totalPage = 0;
		if(totalCount % pageSize == 0 ){
			totalPage = totalCount / pageSize;	
		}else{
			totalPage = totalCount / pageSize + 1;
		}
			return totalPage;
	}
	public int getTotalCount(String firstPartyName){
		return cntractDao.getTotalCount(firstPartyName);
	}
	public Contract getContract(int id) {
		return cntractDao.getContract(id);
	}
	public Contract getContractNo(String contractNo) {
		return cntractDao.getContractNo(contractNo);
	}
}
